package com.boot.mgt.service.impl

import com.boot.core.util.ManagerKit
import com.boot.mgt.dao.mysql.TaLocationReportMapper
import com.boot.mgt.model.TaLocationReport
import com.boot.mgt.service.TaLocationReportService
import com.googlecode.jsonrpc4j.spring.AutoJsonRpcServiceImpl
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

/**
 * @author kawins
 * createTime 2019-03-14 19:37
 */
@AutoJsonRpcServiceImpl
@Service
class TaLocationReportServiceImpl : TaLocationReportService {

    @Autowired
    private lateinit var taLocationReportMapper: TaLocationReportMapper

    override fun insert(taLocationReport: TaLocationReport) {
        taLocationReport.policeNumber = ManagerKit.getPoliceNumber()
        taLocationReportMapper.insert(taLocationReport)
    }

    override fun insertRpc(taLocationReport: TaLocationReport, police_number: String) {
        taLocationReport.policeNumber = police_number
        taLocationReportMapper.insert(taLocationReport)
    }

    override fun selectAll(): List<TaLocationReport> {
        TaLocationReport().apply {
            xqdw = ManagerKit.getOrgNum()
            taLocationReportMapper.select(this)
        }
        return arrayListOf()
    }

    override fun selectByNum(police_number: String): List<TaLocationReport> {
        TaLocationReport().apply {
            if (police_number.isEmpty()) {
                this.policeNumber = ManagerKit.getPoliceNumber()
            } else {
                this.policeNumber = police_number
            }
            return taLocationReportMapper.select(this)
        }
        return arrayListOf()
    }
}